using System;

namespace VCDepend.Engine.Graphviz
{
	public class DotUtil
	{
		private const string IllegalChars = " .,;[]{}";

		public static string EscapeDotString(string value)
		{
			if (NeedsEscaping(value))
				return "\"" + value + "\"";

			return value;
		}

		private static bool NeedsEscaping(string value)
		{
			return ContainsAny(value, IllegalChars);
		}

		private static bool ContainsAny(string value, string chars)
		{
			return (value.IndexOfAny(chars.ToCharArray()) > -1);
		}
	}
}
